
#pragma once

#include "session.h"
#include <memory>
#include <map>
#include <queue>
#include <mutex>
#include <jansson.h>
#include <string>

using std::string;

struct Response {
	string name;
	string res;
};

enum class ProxyStatu {
	S_KO,

	//Error
	E_CommandNotFound,
	E_Json_Dump,
	E_Disconnection,
    E_ClientNotInit,

};

const char* strProxyStatus(int status);

class ClientProxy {
	public:
		static ClientProxy& getInstance();
		void setClient(std::shared_ptr<Session>& clt);
		void setFillBufferObject(string catag, void* object);
		void unSetFillBufferObject(string catag);
		void fillResponseQueue(Response r);


		void send(string type, json_t* json, int& status);
		string recive(string name, int timeout=5);

	private:
		ClientProxy();

		static std::shared_ptr<Session> mClt;
		static std::map<string, void*> mObjectsPool;
		static std::queue<Response> mResponseQueue;
		static std::mutex mMutex;
};
